from django import http
from django.shortcuts import render

# Create your views here.
from django.views import View
from addresses.models import Area


# 提供城区列表
class Areas(View):

    def get(self,request):
        areas = Area.objects.all()
        data = []

        for area in areas:
            area_dict = {'aid' : area.id ,
                         'aname' : area.name }
            data.append(area_dict)

        contents = {'errmsg' : 'ok' ,
                    'errno' : '0' ,
                    'data' : data ,
                    }

        return http.JsonResponse(contents)